import tkinter as tk
import tkinter.messagebox
root=tk.Tk()
root.title("登录界面")
root.geometry("300x100+200+200")
username=tk.StringVar()
password=tk.StringVar()
label1=tk.Label(root,text="用户名",bg="gold",width=20)
label1.grid(row=1,column=1)
label2=tk.Label(root,text="密码",bg="gold",width=20)
label2.grid(row=2,column=1)
input1=tk.Entry(root,width=20,textvariable=username)
input1.grid(row=1,column=2)
input2=tk.Entry(root,width=20,textvariable=password)
input2.grid(row=2,column=2)
def btclick(e):
    u=username.get()
    p=password.get()
    if(u=="admin" and p=="123"):
        tk.messagebox.showinfo(title="提示",message="登录成功")
    else:
        tk.messagebox.showinfo(title="提示",message="登录失败")
button1=tk.Button(root,text="登录")
button1.grid(row=3,column=2)
button1.bind("<Button-1>",btclick)
root.mainloop()